package com.accenture.adf.newcodington.module14.sample;

/**
 * 
 * Topic: Use of the Singleton pattern
 * 
 * Instructions:
 * 1. Use the Singleton.java file
 * 2. Create multiple instances of Singleton objects
 * 3. Print out the results
 *
 */

public class SingletonDemo{

	public static void main(String arg[]){
		
		//Instances of Singleton class are limited to 1
		//Let's create more than one objects and see how many times the constructor is called.
		Singleton s1 = Singleton.getInstance();
		Singleton s2 = Singleton.getInstance();
		Singleton s3 = Singleton.getInstance();
		Singleton s4 = Singleton.getInstance();
		Singleton s5 = Singleton.getInstance();
		
		
		//Let's also check if all these references point to the same object in memory
		System.out.println("Is s1 equal to s2 : " + (s1 == s2));
		System.out.println("Is s2 equal to s3 : " + (s2 == s3));
		System.out.println("Is s3 equal to s4 : " + (s3 == s4));
		System.out.println("Is s4 equal to s5 : " + (s4 == s5));
		
		
		
		
	}
}
